<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="insn.css"/><meta name="generator" content="iform.xsl"/><title>FTMAD</title></head><body><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="sveindex.html">SVE Instructions</a></div></td><td><div class="topbar"><a href="mortlachindex.html">SME Instructions</a></div></td><td><div class="topbar"><a href="encodingindex.html">Index by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><hr/><h2 class="instruction-section">FTMAD</h2><p>Floating-point trigonometric multiply-add coefficient</p>
      <p class="aml">The <span class="asm-code">FTMAD</span> instruction calculates the series terms for either <span class="arm-defined-word">sin(x)</span> or <span class="arm-defined-word">cos(x)</span>, where the argument <span class="arm-defined-word">x</span> has been adjusted to be in the range -π/4 &lt; <span class="arm-defined-word">x</span> ≤ π/4.</p>
      <p class="aml">To calculate the series terms of <span class="arm-defined-word">sin(x)</span> and <span class="arm-defined-word">cos(x)</span> the initial source operands of <span class="asm-code">FTMAD</span> should be zero in the first source vector and <span class="arm-defined-word">x</span><sup>2</sup> in the second source vector. The <span class="asm-code">FTMAD</span> instruction is then executed eight times to calculate the sum of eight series terms, which gives a result of sufficient precision.</p>
      <p class="aml">The <span class="asm-code">FTMAD</span> instruction multiplies each element of the first source vector by the absolute value of the corresponding element of the second source vector and performs a fused addition of each product with a value obtained from a table of hard-wired coefficients, and places the results destructively in the first source vector.</p>
      <p class="aml">The coefficients are different for <span class="arm-defined-word">sin(x)</span> and <span class="arm-defined-word">cos(x)</span>, and are selected by a combination of the sign bit in the second source element and an immediate index in the range 0 to 7.</p>
      <p class="aml"/>
      <p class="aml">Double-precision coefficient table for sin(x) (s2&lt;63&gt; == '0')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3ff0 0000 0000 0000</td>
              <td class="">1.0</td>
              <td class="">= 1/1!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">bfc5 5555 5555 5543</td>
              <td class="">-0.1666666666666661</td>
              <td class="">&gt; -1/3!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">3f81 1111 1110 f30c</td>
              <td class="">0.8333333333320002e-02</td>
              <td class="">&lt; 1/5!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">bf2a 01a0 19b9 2fc6</td>
              <td class="">-0.1984126982840213e-03</td>
              <td class="">&gt; -1/7!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">3ec7 1de3 51f3 d22b</td>
              <td class="">0.2755731329901505e-05</td>
              <td class="">&lt; 1/9!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">be5a e5e2 b60f 7b91</td>
              <td class="">-0.2505070584637887e-07</td>
              <td class="">&gt; -1/11!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">3de5 d840 8868 552f</td>
              <td class="">0.1589413637195215e-09</td>
              <td class="">&lt; 1/13!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">0000 0000 0000 0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/15!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">Double-precision coefficient table for cos(x) (s2&lt;63&gt; == '1')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3ff0 0000 0000 0000</td>
              <td class="">1.0</td>
              <td class="">= 1/0!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">bfe0 0000 0000 0000</td>
              <td class="">-0.5000000000000000</td>
              <td class="">= -1/2!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">3fa5 5555 5555 5536</td>
              <td class="">0.4166666666666645e-01</td>
              <td class="">&lt; 1/4!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">bf56 c16c 16c1 3a0b</td>
              <td class="">-0.1388888888886111e-02</td>
              <td class="">&gt; -1/6!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">3efa 01a0 19b1 e8d8</td>
              <td class="">0.2480158728388683e-04</td>
              <td class="">&lt; 1/8!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">be92 7e4f 7282 f468</td>
              <td class="">-0.2755731309913950e-06</td>
              <td class="">&gt; -1/10!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">3e21 ee96 d264 1b13</td>
              <td class="">0.2087558253975872e-08</td>
              <td class="">&lt; 1/12!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">bda8 f763 80fb b401</td>
              <td class="">-0.1135338700720054e-10</td>
              <td class="">&gt; -1/14!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">Single-precision coefficient table for sin(x) (s2&lt;31&gt; == '0')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3f80 0000</td>
              <td class="">1.0</td>
              <td class="">= 1/1!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">be2a aaab</td>
              <td class="">-1.666666716337e-01</td>
              <td class="">&gt; -1/3!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">3c08 8886</td>
              <td class="">8.333330973983e-03</td>
              <td class="">&lt; 1/5!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">b950 08b9</td>
              <td class="">-1.983967522392e-04</td>
              <td class="">&gt; -1/7!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">3636 9d6d</td>
              <td class="">2.721174723774e-06</td>
              <td class="">&lt; 1/9!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/11!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/13!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/15!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">Single-precision coefficient table for cos(x) (s2&lt;31&gt; == '1')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3f80 0000</td>
              <td class="">1.0</td>
              <td class="">= 1/0!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">bf00 0000</td>
              <td class="">-5.000000000000e-01</td>
              <td class="">= -1/2!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">3d2a aaa6</td>
              <td class="">4.166664928198e-02</td>
              <td class="">&lt; 1/4!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">bab6 0705</td>
              <td class="">-1.388759003021e-03</td>
              <td class="">&gt; -1/6!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">37cd 37cc</td>
              <td class="">2.446388680255e-05</td>
              <td class="">&lt; 1/8!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/10!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/12!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">0000 0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/14!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">Half-precision coefficient table for sin(x) (s2&lt;15&gt; == '0')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3c00</td>
              <td class="">1.0</td>
              <td class="">= 1/1!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">b155</td>
              <td class="">-1.666666716337e-01</td>
              <td class="">&gt; -1/3!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">2030</td>
              <td class="">8.333330973983e-03</td>
              <td class="">&lt; 1/5!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/7!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/9!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/11!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/13!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/15!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">Half-precision coefficient table for cos(x) (s2&lt;15&gt; == '1')</p>
      <table class="valuetable">
        
          <thead>
            <tr>
              <th class="">Index</th>
              <th class="">Hexadecimal</th>
              <th class="">Decimal</th>
              <th class="">Exact Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="">0</td>
              <td class="">3c00</td>
              <td class="">1.0</td>
              <td class="">= 1/0!</td>
            </tr>
            <tr>
              <td class="">1</td>
              <td class="">b800</td>
              <td class="">-5.000000000000e-01</td>
              <td class="">= -1/2!</td>
            </tr>
            <tr>
              <td class="">2</td>
              <td class="">293a</td>
              <td class="">4.166664928198e-02</td>
              <td class="">&lt; 1/4!</td>
            </tr>
            <tr>
              <td class="">3</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/6!</td>
            </tr>
            <tr>
              <td class="">4</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/8!</td>
            </tr>
            <tr>
              <td class="">5</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/10!</td>
            </tr>
            <tr>
              <td class="">6</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&lt; 1/12!</td>
            </tr>
            <tr>
              <td class="">7</td>
              <td class="">0000</td>
              <td class="">0.0</td>
              <td class="">&gt; -1/14!</td>
            </tr>
          </tbody>
        
      </table>
      <p class="aml">This instruction is illegal when executed in Streaming SVE mode, unless FEAT_SME_FA64 is implemented and enabled.</p>
    
    <p class="desc"/><div class="regdiagram-32"><table class="regdiagram"><thead><tr><td>31</td><td>30</td><td>29</td><td>28</td><td>27</td><td>26</td><td>25</td><td>24</td><td>23</td><td>22</td><td>21</td><td>20</td><td>19</td><td>18</td><td>17</td><td>16</td><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></thead><tbody><tr class="firstrow"><td class="l">0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td><td>0</td><td class="r">1</td><td colspan="2" class="lr">size</td><td class="l">0</td><td>1</td><td class="r">0</td><td colspan="3" class="lr">imm3</td><td class="l">1</td><td>0</td><td>0</td><td>0</td><td>0</td><td class="r">0</td><td colspan="5" class="lr">Zm</td><td colspan="5" class="lr">Zdn</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding"/><a id="ftmad_z_zzi_"/><p class="asm-code">FTMAD   <a href="#sa_zdn" title="First source and destination scalable vector register (field &quot;Zdn&quot;)">&lt;Zdn&gt;</a>.<a href="#sa_t" title="Size specifier (field &quot;size&quot;) [D,H,S]">&lt;T&gt;</a>, <a href="#sa_zdn" title="First source and destination scalable vector register (field &quot;Zdn&quot;)">&lt;Zdn&gt;</a>.<a href="#sa_t" title="Size specifier (field &quot;size&quot;) [D,H,S]">&lt;T&gt;</a>, <a href="#sa_zm" title="Second source scalable vector register (field &quot;Zm&quot;)">&lt;Zm&gt;</a>.<a href="#sa_t" title="Size specifier (field &quot;size&quot;) [D,H,S]">&lt;T&gt;</a>, #<a href="#sa_imm" title="Unsigned immediate operand [0-7] (field &quot;imm3&quot;)">&lt;imm&gt;</a></p></div><p class="pseudocode">if !<a href="shared_pseudocode.html#impl-aarch64.HaveSVE.0" title="function: boolean HaveSVE()">HaveSVE</a>() then UNDEFINED;
if size == '00' then UNDEFINED;
constant integer esize = 8 &lt;&lt; <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(size);
integer dn = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(Zdn);
integer m = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(Zm);
integer imm = <a href="shared_pseudocode.html#impl-shared.UInt.1" title="function: integer UInt(bits(N) x)">UInt</a>(imm3);</p>
  <div class="encoding-notes"/><h3 class="explanations">Assembler Symbols</h3><div class="explanations"><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Zdn&gt;</td><td><a id="sa_zdn"/>
        
          <p class="aml">Is the name of the first source and destination scalable vector register, encoded in the "Zdn" field.</p>
        
      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;T&gt;</td><td><a id="sa_t"/>
        <p>Is the size specifier, 
      encoded in
      <q>size</q>:
        </p>
        <table class="valuetable">
          
            <thead>
              <tr>
                <th class="bitfield">size</th>
                <th class="symbol">&lt;T&gt;</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td class="bitfield">00</td>
                <td class="symbol">RESERVED</td>
              </tr>
              <tr>
                <td class="bitfield">01</td>
                <td class="symbol">H</td>
              </tr>
              <tr>
                <td class="bitfield">10</td>
                <td class="symbol">S</td>
              </tr>
              <tr>
                <td class="bitfield">11</td>
                <td class="symbol">D</td>
              </tr>
            </tbody>
          
        </table>
      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Zm&gt;</td><td><a id="sa_zm"/>
        
          <p class="aml">Is the name of the second source scalable vector register, encoded in the "Zm" field.</p>
        
      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;imm&gt;</td><td><a id="sa_imm"/>
        
          <p class="aml">Is the unsigned immediate operand, in the range 0 to 7, encoded in the "imm3" field.</p>
        
      </td></tr></table></div><div class="syntax-notes"/>
    <div class="ps"><a id="execute"/><h3 class="pseudocode">Operation</h3>
      <p class="pseudocode"><a href="shared_pseudocode.html#impl-aarch64.CheckNonStreamingSVEEnabled.0" title="function: CheckNonStreamingSVEEnabled()">CheckNonStreamingSVEEnabled</a>();
constant integer VL = <a href="shared_pseudocode.html#impl-aarch64.CurrentVL.read.none" title="accessor: integer CurrentVL">CurrentVL</a>;
constant integer PL = VL DIV 8;
constant integer elements = VL DIV esize;
bits(VL) operand1 = <a href="shared_pseudocode.html#impl-aarch64.Z.read.2" title="accessor: bits(width) Z[integer n, integer width]">Z</a>[dn, VL];
bits(VL) operand2 = <a href="shared_pseudocode.html#impl-aarch64.Z.read.2" title="accessor: bits(width) Z[integer n, integer width]">Z</a>[m, VL];
bits(VL) result;

for e = 0 to elements-1
    bits(esize) element1 = <a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand1, e, esize];
    bits(esize) element2 = <a href="shared_pseudocode.html#impl-shared.Elem.read.3" title="accessor: bits(size) Elem[bits(N) vector, integer e, integer size]">Elem</a>[operand2, e, esize];
    <a href="shared_pseudocode.html#impl-shared.Elem.write.3" title="accessor: Elem[bits(N) &amp;vector, integer e, integer size] = bits(size) value">Elem</a>[result, e, esize] = <a href="shared_pseudocode.html#impl-aarch64.FPTrigMAdd.4" title="function: bits(N) FPTrigMAdd(integer x_in, bits(N) op1, bits(N) op2_in, FPCRType fpcr)">FPTrigMAdd</a>(imm, element1, element2, FPCR[]);

<a href="shared_pseudocode.html#impl-aarch64.Z.write.2" title="accessor: Z[integer n, integer width] = bits(width) value">Z</a>[dn, VL] = result;</p>
    </div>
  <h3>Operational information</h3><p class="aml">
          This instruction might be immediately preceded in program order by a <span class="asm-code">MOVPRFX</span> instruction. The <span class="asm-code">MOVPRFX</span> instruction must conform to all of the following requirements, otherwise the behavior of the <span class="asm-code">MOVPRFX</span> and this instruction is <span class="arm-defined-word">unpredictable</span>:
        </p><ul><li>The <span class="asm-code">MOVPRFX</span> instruction must be unpredicated.</li><li>The <span class="asm-code">MOVPRFX</span> instruction must specify the same destination register as this instruction.</li><li>The destination register must not refer to architectural register state referenced by any other source operand register of this instruction.</li></ul><hr/><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="sveindex.html">SVE Instructions</a></div></td><td><div class="topbar"><a href="mortlachindex.html">SME Instructions</a></div></td><td><div class="topbar"><a href="encodingindex.html">Index by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><p class="versions">
      Internal version only: isa v33.62, AdvSIMD v29.12, pseudocode v2023-03_rel, sve v2023-03_rc3b
      ; Build timestamp: 2023-03-31T11:36
    </p><p class="copyconf">
      Copyright © 2010-2023 Arm Limited or its affiliates. All rights reserved.
      This document is Non-Confidential.
    </p></body></html>
